package com.jsy.listener;

import com.jsy.common.constant.RabbitMQConstant;
import com.jsy.common.dto.Message;
import com.jsy.item.feign.PageFeign;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ItemPageMessage {

    @Autowired
    private PageFeign pageFeign;

    @RabbitListener(queues = RabbitMQConstant.SPU_TOPIC_QUEUE)
    public void receive(Message message){
        //spu id
        long spuId = Long.parseLong(message.getContent().toString());
        if (Message.TYPE_GOODS_AUDIT.equals(message.getType())){
            pageFeign.createHtml(spuId);
        }else {
            pageFeign.deleteHtml(spuId);
        }
    }
}
